/**
 * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package com.sample.library.model.impl;

import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.model.CacheModel;

import com.sample.library.model.Author;

import java.io.Serializable;

import java.util.Date;

/**
 * The cache model class for representing Author in entity cache.
 *
 * @author Nguyen Tuan Anh
 * @see Author
 * @generated
 */
public class AuthorCacheModel implements CacheModel<Author>, Serializable {
	@Override
	public String toString() {
		StringBundler sb = new StringBundler(13);

		sb.append("{authorId=");
		sb.append(authorId);
		sb.append(", firstMiddleName=");
		sb.append(firstMiddleName);
		sb.append(", lastName=");
		sb.append(lastName);
		sb.append(", fullName=");
		sb.append(fullName);
		sb.append(", birthDay=");
		sb.append(birthDay);
		sb.append(", email=");
		sb.append(email);
		sb.append("}");

		return sb.toString();
	}

	public Author toEntityModel() {
		AuthorImpl authorImpl = new AuthorImpl();

		authorImpl.setAuthorId(authorId);

		if (firstMiddleName == null) {
			authorImpl.setFirstMiddleName(StringPool.BLANK);
		}
		else {
			authorImpl.setFirstMiddleName(firstMiddleName);
		}

		if (lastName == null) {
			authorImpl.setLastName(StringPool.BLANK);
		}
		else {
			authorImpl.setLastName(lastName);
		}

		if (fullName == null) {
			authorImpl.setFullName(StringPool.BLANK);
		}
		else {
			authorImpl.setFullName(fullName);
		}

		if (birthDay == Long.MIN_VALUE) {
			authorImpl.setBirthDay(null);
		}
		else {
			authorImpl.setBirthDay(new Date(birthDay));
		}

		if (email == null) {
			authorImpl.setEmail(StringPool.BLANK);
		}
		else {
			authorImpl.setEmail(email);
		}

		authorImpl.resetOriginalValues();

		return authorImpl;
	}

	public long authorId;
	public String firstMiddleName;
	public String lastName;
	public String fullName;
	public long birthDay;
	public String email;
}